package com.fengwk.cv4j.view.common;

import com.fengwk.cv4j.compute.Compute;
import com.fengwk.cv4j.factory.ViewFactory;
import com.fengwk.cv4j.view.View;
import com.fengwk.cv4j.view.ViewImpl;
import com.fengwk.support.exception.BaseException;

/**
 * 通用的equals算子
 * 
 * @author fengwk
 *
 */
public class EqualsView<T> extends ViewImpl<T> {

	private static final long serialVersionUID = 3431905680259947626L;

	public EqualsView(Compute<T> compute, ViewFactory<T> factory, @SuppressWarnings("unchecked") View<T>...vs) {
		super(compute, factory, vs);
		checkVs(2, vs);
	}

	@Override
	protected T compute0() {
		return c().equals(t(0), t(1));
	}

	@Override
	protected View<T> gradient0(int idx) {
		throw new BaseException("can't support equals gradient");
	}
	
	@Override
    public String toString() {
        return "equals";
    }

}
